package github.kawaiior.yuanchuxiuzhen.common.block.ore;

import github.kawaiior.yuanchuxiuzhen.common.world.dimension.YcxzTeleporter;
import github.kawaiior.yuanchuxiuzhen.core.init.DimensionInit;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;

public class ManaStoneOre extends Block {
    private int level;
    public ManaStoneOre(int level) {
        super(Properties.create(Material.ROCK).hardnessAndResistance(1.5f,20f));
        this.level = level;
    }
    public ManaStoneOre(int level, float hardness) {
        super(Properties.create(Material.ROCK).hardnessAndResistance(hardness,20f));
        this.level = level;
    }
    public ManaStoneOre(int level, float hardness, float resistance) {
        super(Properties.create(Material.ROCK).hardnessAndResistance(hardness,resistance));
        this.level = level;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    // 测试用
//    @Override
//    public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
//
//        if (worldIn.isRemote || player.isCrouching()){
//            return super.onBlockActivated(state, worldIn, pos, player, handIn, hit);
//        }
//
//        MinecraftServer server = worldIn.getServer();
//        if (server==null){
//            return super.onBlockActivated(state, worldIn, pos, player, handIn, hit);
//        }
//        ServerWorld world;
//        boolean flag = false;
//        if (worldIn.getDimensionKey() == DimensionInit.HELL){
//            world = server.getWorld(World.OVERWORLD);
//        }else {
//            world = server.getWorld(DimensionInit.HELL);
//            flag = true;
//        }
//
//        if (world == null) {
//            return super.onBlockActivated(state, worldIn, pos, player, handIn, hit);
//        }
//
//        player.changeDimension(world, new YcxzTeleporter(pos, flag));
//
//        return super.onBlockActivated(state, worldIn, pos, player, handIn, hit);
//    }

    @Override
    public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) {
        super.onBlockHarvested(worldIn, pos, state, player);
    }
}
